//
//  ViewController.swift
//  MSwift
//
//  Created by 马龙波 on 2017/10/27.
//  Copyright © 2017年 马龙波. All rights reserved.
//

import UIKit

class BoardController: BaseController {

    /**内部属性*/
    fileprivate let titleArr = ["label&button", "tableView", "collecttionView"];
    //懒加载
    fileprivate lazy var tableView : UITableView = {
        let temTableView = UITableView(frame: CGRect(x: 0, y: 0, width: kScreenW, height: kScreenH-kNavgationH-kTabBarH), style: .plain)
        temTableView.delegate = self
        temTableView.dataSource = self
        temTableView.backgroundColor = UIColor.green
        temTableView.tableFooterView = UIView()
        temTableView.register(BoardCell.classForCoder(), forCellReuseIdentifier: "TbCell")
        view.addSubview(temTableView)
        return temTableView
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationItem.title = "大伙"
        kLog("hahahahahah")
        kLog("kStatusHeight->\(kStatusH)")
        tableView .reloadData()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

extension BoardController {
    func createTable() {
        
    }
}

extension BoardController: UITableViewDelegate,UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return titleArr.count
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 40.0
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let identifier = "mycell"
        var cell = tableView.dequeueReusableCell(withIdentifier: identifier)
        if cell == nil {
            cell = UITableViewCell(style: .default, reuseIdentifier: identifier)
        }
        cell?.accessoryType = UITableViewCellAccessoryType.disclosureIndicator
        cell?.textLabel?.text = "cell->\(indexPath.row)--\(titleArr[indexPath.row])"
        
        return cell!
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView .reloadData()

//        let testVC = TestController()
//        testVC.str = "测试"
        self.navigationController?.pushViewController(NextController(), animated: true)
    }
}

